import 'swiper/css/swiper.min.css'
import Swiper from 'swiper'

import './scss/style.scss'
import 'bootstrap'

//首页轮播
(function () {
    new Swiper ('.index-swiper .swiper-container', {

        loop: true,

        pagination: {
            el: '.index-swiper .swiper-pagination',
        },

        // 如果需要前进后退按钮
        navigation: {
            nextEl: '.index-swiper .swiper-button-next',
            prevEl: '.index-swiper .swiper-button-prev',
        }

    })


    var apply1 = new Swiper ('.index-apply__1.swiper-container', {

        loop: true,
        spaceBetween: 0,
        initialSlide : 2,
        slidesPerView: 'auto',
        centeredSlides: true,

    })

    var apply2 = new Swiper ('.index-apply__2.swiper-container', {

        loop: true,
        spaceBetween: 0,
        initialSlide: 1,
        slidesPerView: 'auto',
        centeredSlides: true,

    })

    var apply3 = new Swiper ('.index-apply__3.swiper-container', {
        loop: true,
        spaceBetween: 0,
        slidesPerView: 'auto',
        initialSlide : 1,
        centeredSlides: true,
        allowTouchMove: false,
        // 如果需要前进后退按钮
        navigation: {
            nextEl: '.index-apply .swiper-button-next',
            prevEl: '.index-apply .swiper-button-prev',
        },
        on:{
            slideNextTransitionStart: function () {
                apply1.slideNext()
                apply2.slideNext()
            },
            slidePrevTransitionStart: function () {
                apply1.slidePrev()
                apply2.slidePrev()
            }
        }
    })
})();

(function () {
    var galleryThumbs = new Swiper('.use-swiper .gallery-thumbs', {
        spaceBetween: 10,
        slidesPerView: 4,
        loop: true,
        freeMode: true,
        loopedSlides: 5, //looped slides should be the same
        watchSlidesVisibility: true,
        watchSlidesProgress: true,
    });
    var galleryTop = new Swiper('.use-swiper .gallery-top', {
        spaceBetween: 10,
        loop:true,
        loopedSlides: 5, //looped slides should be the same
        navigation: {
            nextEl: '.use-swiper .swiper-button-next',
            prevEl: '.use-swiper .swiper-button-prev',
        },
        thumbs: {
            swiper: galleryThumbs,
        },
    });

    if(document.querySelector('#map')){
        var map = new BMap.Map("map");
        var point = new BMap.Point(114.26204,34.813452);
        map.centerAndZoom(point, 16);
        var marker = new BMap.Marker(point);        // 鍒涘缓鏍囨敞
        map.addOverlay(marker);    // 灏嗘爣娉ㄦ坊鍔犲埌鍦板浘涓�
        map.addControl(new BMap.NavigationControl());
        map.addControl(new BMap.ScaleControl());

        window.onresize = function () {
            map.addOverlay(marker);    // 灏嗘爣娉ㄦ坊鍔犲埌鍦板浘涓�
        }
    }
})();